﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Composite.UnityExtensions;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Unity;
using uTorrentNetClient.ModelDesign.EditSettings;
using uTorrentNetClient.ModelDesign.EditSettings.Controller;
using uTorrentNetClient.ModelDesign.EditSettings.Model;
using uTorrentNetClient.ModelDesign.EditSettings.View;
using uTorrentNetClient.ModelDesign.Main;
using uTorrentNetClient.ModelDesign.Contracts;
using uTorrentNetClient.ModelDesign.Main.View;
using uTorrentNetClient.ModelDesign.Main.Model;
using System.Windows;
using uTorrentNetClient.ModelDesign.Notify;
using uTorrentNetClient.ModelDesign.NotifyWindow.Model;
using uTorrentNetClient.ModelDesign.NotifyWindow.View;
using uTorrentNetClient.ModelDesign.Settings.Model;
using uTorrentNetClient.ModelDesign.TorrentProperties.Model;
using uTorrentNetClient.ModelDesign.TorrentProperties.View;
using uTorrentNetClient.ModelDesign.Settings;
using uTorrentNetClient.ModelDesign.TorrentProperties;
using uTorrentNetClient.ModelDesign.Settings.Controller;
using uTorrentNetClient.ModelDesign.Settings.View;
using uTorrentNetClient.ModelDesign.TorrentProperties.Controller;

namespace uTorrentNetClient
{
    public class BootStrapper : UnityBootstrapper
    {
        protected override DependencyObject CreateShell()
        {
            var view = Container.Resolve<IShellView>();
            view.ShowView();

            return view as DependencyObject;
        }

        protected override IModuleCatalog GetModuleCatalog()
        {
            var catalog = new ModuleCatalog();
            catalog.AddModule(typeof(MainModul))
                .AddModule(typeof(SettingsModul))
                .AddModule(typeof(PropertiesModul))
                .AddModule(typeof(EditSettingsModul));

            return catalog;
        }

        protected override void ConfigureContainer()
        {
            Container.RegisterType<IShellView, ShellView>(new ContainerControlledLifetimeManager());

            Container.RegisterType<INotify, Notify>();

            Container.RegisterType<IMainView, MainView>();
            Container.RegisterType<IMainModel, MainModel>();

            Container.RegisterType<ISettingsModel, SettingsModel>();
            Container.RegisterType<ISettingsView, SettingsView>();
            Container.RegisterType<ISettingsController, SettingsController>();

            Container.RegisterType<IPropertiesModel, PropertiesModel>();
            Container.RegisterType<IPropertiesView, PropertiesView>();
            Container.RegisterType<IPropertiesController, PropertiesController>();

            Container.RegisterType<IEditSettingsController, EditSettingsController>();
            Container.RegisterType<IEditSettingsModel, EditSettingsModel>();
            Container.RegisterType<IEditSettingsView, EditSettingsView>();

            Container.RegisterType<INotifyWindowView, NotifyWindowView>(new ContainerControlledLifetimeManager());
            Container.RegisterType<INotifyWindowModel, NotifyWindowModel>();


            base.ConfigureContainer();
        }
    }
}
